package com.mengwen.backstage.controller;

import com.mengwen.backstage.api.accesstoken.GetLastAcceccToken;
import com.mengwen.backstage.util.WeixinUtil;
import net.sf.json.JSONObject;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author LiangYonghui
 * @date 2020/3/24 15:41
 * @description
 */
public class GetCodeController {

    String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN";
    public void getCode() throws Exception {
        JSONObject jsonObject = WeixinUtil.httpRequest(url.replace("TOKEN", GetLastAcceccToken.getAccessToken(new RedisTemplate()).getToken()), "POST", "{\"expire_seconds\": 604800, \"action_name\": \"QR_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": 123}}} ");
        System.out.println(jsonObject);
    }


    public static void main(String[] args) throws Exception {
        GetCodeController codeController = new GetCodeController();
        codeController.getCode();
    }
}
